package com.suray.wcs.web.system.controller;

import com.suray.commin.annotation.Log;
import com.suray.commin.core.controller.BaseController;
import com.suray.commin.core.controller.ResponseData;
import com.suray.commin.core.page.TableDataInfo;
import com.suray.commin.core.utils.ExcelUtil;
import com.suray.commin.enmus.BusinessType;
import com.suray.wcs.service.system.entity.RgvLogDB;
import com.suray.wcs.service.system.service.impl.RgvLogServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rgvLog")
@CrossOrigin(value = "*", allowCredentials = "true")
public class RgvLogController extends BaseController {

    @Autowired
    private RgvLogServiceImpl rgvLogService;

    /**
     * 分页查询
     * @param rgvLogDB
     * @return
     */
    @PreAuthorize("@ss.hasPermi('rgvLog:list')")
    @ApiOperation(value = "查询接口日志")
    @GetMapping(value = "/list")
    @ResponseBody
    public TableDataInfo list(RgvLogDB rgvLogDB){
        startPage();
        List<RgvLogDB> rgvLogDBS = rgvLogService.getRgvLogs(rgvLogDB);
        return getDataTable(rgvLogDBS);
    }

    @Log(title = "小车交互日志", method = "导出小车交互日志", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('rgvLog:export')")
    @GetMapping("/export")
    public ResponseData export(RgvLogDB rgvLogDB){
        List<RgvLogDB> list = rgvLogService.getRgvLogs(rgvLogDB);
        ExcelUtil<RgvLogDB> util = new ExcelUtil<>(RgvLogDB.class);
        return util.exportExcel(list,"小车交互日志");
    }

    @PreAuthorize("@ss.hasAnyPermi('rgvLog:remove')")
    @DeleteMapping("/{rgvLogIds}")
    public ResponseData remove(@PathVariable Long[] rgvLogIds){
        return toAjax(rgvLogService.deleteRgvLogByIds(rgvLogIds));
    }

    @Log(title = "小车交互日志",method = "清空小车交互日志", businessType = BusinessType.CLEAN)
    @PreAuthorize("@ss.hasAnyPermi('rgvLog:clean')")
    @DeleteMapping("/clean")
    public ResponseData clean(){
        rgvLogService.cleanRgvLog();
        return ResponseData.success();
    }
}
